<!doctype html>
<html xmlns:th="http://www.thymeleaf.org"  lang="zh-CN">
<head>
  <title>清华大学学生教育互联网公益协会</title>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
  <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" />
  <script th:src = "@{/js/jquery.min.js}"></script>
  <script th:src = "@{/js/bootstrap.min.js}"></script>

  <style>
    .navbar-brand {
      padding: 0 15px;
    }
    textarea {
    	overflow: visible;
    }
    p.form-control {
    	height: auto;
    }
  </style>
</head>
<body>
  <div class="container">
    <header>
      <nav class="navbar navbar-default bg-faded">
        <div class="container-fluid">
          <!-- Brand and toggle get grouped for better mobile display -->
          <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" th:href="@{'/' + ${domain==null?'':domain} }">
              <img th:src="@{/img/brand.jpg}" height="50"/>
            </a>
          </div>

          <!-- Collect the nav links, forms, and other content for toggling -->
          <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
              <li class="nav-item"><a th:href="@{'/' + ${domain==null?'':domain} }">i玩问答</a></li>
              <li class="nav-item"><a th:href="@{/profile}">个人信息</a></li>
              <li class="nav-item"><a th:if="${domain == null}" th:href="@{/volunteers}">哥哥姐姐</a></li>
              <li class="nav-item"><a th:if="${domain == null}" th:href="@{/look}">i玩课堂</a></li>
              <li class="nav-item"><a th:href="@{/logout}">退出登录</a></li>
            </ul>
          </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
      </nav>
    </header>
    <main>

      <div class="question">
        <h2 class="text-center" th:text="${question.title}"></h2>
        <div class="form-horizontal">
          <div class="form-group">
            <label for="description" class="col-sm-2 control-label">
              <span class="label label-info" th:text="${question.creator.displayName}"></span>
            </label>
            <div class="col-sm-10">
              <p class="form-control" id="content" th:text="${question.description}"></p>
              <!--  
              <textarea class="form-control" id="description" readonly="true" 
              	th:inline="text">[[${question.description}]]</textarea>
              -->
            </div>
          </div>
        </div>
      </div>
      
      <div th:each="reply : ${replies}" class="form-horizontal clearfix">
        <div class="clearfix"></div>
        <div class="form-group">
          <label for="title" class="col-sm-2 control-label">
            <span 
              th:class="${'label ' + (reply.creator.id==question.creator.id? 'label-info':'label-warning') }" 
              th:text="${reply.creator.displayName}"></span>
          </label>
          <div class="col-sm-10">
          	<p class="form-control" id="content" th:text="${reply.content}"></p>
          </div>
        </div>
      </div>
      
      <form id="reply" class="form-horizontal" method="post" th:if="${question.status.toString() != 'CLOSED'} ">
        <div class="form-group">
          <label 
            for="content" 
            class="col-sm-2 control-label" 
            th:text="${user.id==question.creator.id?'补充：':'回复：'}"></label>
          <div class="col-sm-10">
            <textarea id="content" name="content" class="form-control" rows="3" required="required"></textarea>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary">保存</button>
          </div>
        </div>
      </form>
      <form id="reply" class="form-horizontal" method="post" 
        th:action="@{/question/{questionId}/close(questionId=${question.Id})}"
      	th:if="${question.status.toString() != 'CLOSED' and question.creator.id == user.id} ">
        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary">已经懂了</button>
          </div>
        </div>
      </form>
      <p class="text-info text-center" th:if="${success != null}" th:text="${success}"></p>
      <p class="text-danger text-center" th:if="${error != null}" th:text="${error}"></p>
      <p class="text-info text-center" th:if="${question.status.toString() == 'CLOSED'}">该问题已关闭</p>

    </main>
  </div>
</body>
</html>
